import requests
import common.config
from common.config import *

class DeviceBoard:
    def latestTaskTime(self,env):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/device/latestTaskTime"
        token=getToken(env)
        self.data = Excel(data_path+'deviceBoard.xlsx')
        header=eval(self.data[0][5])
        header['token'] = token
        r = requests.get(url, headers=header)
        print('最新数据时间',r.json())
        return r.json()

    def overview(self,env,dt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/device/overview"
        token = getToken(env)
        self.data = Excel(data_path + 'deviceBoard.xlsx')
        header = eval(self.data[1][5])
        header['token'] = token
        params1 = {"dt": dt}
        r = requests.get(url, headers=header,params=params1)
        #print('设备比重', r.json())
        return r.json()

    def heatmap(self,env,dt,key):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/device/heatmap"
        token = getToken(env)
        self.data = Excel(data_path + 'deviceBoard.xlsx')
        header = eval(self.data[2][5])
        header['token'] = token
        #print(key)
        #type=str(key).replace('(', '').replace(')', '').replace(',', '').replace("'", "")
        params1 = {"dt": dt,"type":key}
        r = requests.get(url, headers=header, params=params1)
        # print('设备比重', r.json())
        #print (r.json())
        return r.json()


#a=DeviceBoard()
#a.heatmap('test','2020-06-01','')







